package tcp.status;

import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import tcp.Watcher;
import tcp.heartbeat.HeartbeatHandler;

public class StatusUpdateManager {

	public static final int UPDATE_CHECK_PERIOD = 10;
	public static final int NUMBER_OF_STATUSUPDATE_THREADS = 4;
	private Watcher itemWatcher;
	
	private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(NUMBER_OF_STATUSUPDATE_THREADS);
	
	public StatusUpdateManager(Watcher watcher){
		scheduler.scheduleAtFixedRate(new StatusUpdateHandler(this), 10, 10, TimeUnit.SECONDS);
		this.itemWatcher = watcher;
	}
	public List getWatchedFileStores(String type){
		return this.itemWatcher.getListOfWatchedElements(type);
	}
	public void removeUnresponseFileStoreNode(String id){
		this.itemWatcher.removeWatchedElement(id) ;
	}
}
